<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/js/jquery.js"></script>
    <link rel="stylesheet" href="/css/element-ui@2.13.2.index.css">
    <script src="/js/vue.min.js"></script>
    <script src="/js/vue-resource.min.js"></script>
    <script src="/js/index.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/axios.min.js"></script>
    <!-- 字体图标css的引入 -->
    <link rel="stylesheet" href="/css/font_830376_qzecyukz0s.css">
    <link rel="stylesheet" href="/css/color-dark.css">
    <link rel="stylesheet" href="/css/icon.css">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery.slim.min.js"></script>
    <script src="/js/popper.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <title></title>
</head>

<body>
    <div id="manage">
        <!-- 头部 -->
        <div class="wrapper">
            <!-- 头部 -->
            <div class="header">
                <!-- 折叠按钮 -->
                <div class="header-left">
                    人脸库管理
                </div>

                <!-- <div class="logo">后台管理系统</div> -->
                <div class="header-right">
                    <div class="header-user-con">
                        <!-- 全屏显示 -->
                        <div class="btn-fullscreen" @click="handleFullScreen">
                            <el-tooltip effect="dark" :content="fullscreen?`取消全屏`:`全屏`" placement="bottom">
                                <i class="el-icon-rank"></i>
                            </el-tooltip>
                        </div>
                        <div class="user-avator">
                            <img src="/image/img.jpg" />
                        </div>
                        <!-- 用户名下拉菜单 -->
                        <el-dropdown class="user-name" trigger="click" @command="handleCommand">
                            <span class="el-dropdown-link">
                                {{username}}
                                <i class="el-icon-caret-bottom"></i>
                            </span>
                            <el-dropdown-menu slot="dropdown">
                                <a href="https://github.com/lin-xin/vue-manage-system" target="_blank">
                                    <el-dropdown-item>项目仓库</el-dropdown-item>
                                </a>
                                <el-dropdown-item divided command="loginout">退出登录</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </div>
                </div>
            </div>

            <!-- 侧边部分 -->
            <div data-v-68d67528="" class="sidebar">
                <ul data-v-68d67528="" role="menubar" class="sidebar-el-menu el-menu side-ul"
                    style="background-color: rgb(50, 65, 87);">
                    <li data-v-68d67528="" role="menuitem" tabindex="-1" class="el-menu-item"
                        style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(50, 65, 87);"><i
                            data-v-68d67528="" class="el-icon-lx-home"></i><span data-v-68d67528="">首页</span></li>
                    <li data-v-68d67528="" role="menuitem" tabindex="-1" class="el-menu-item  is-active"
                        style="padding-left: 20px; color: rgb(32, 160, 255); background-color: rgb(50, 65, 87);"><i
                            data-v-68d67528="" class="el-icon-lx-calendar"></i><span data-v-68d67528="">人脸库管理</span>
                    </li>
                    <li data-v-68d67528="" role="menuitem" tabindex="-1" class="el-menu-item"
                        style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(50, 65, 87);"><i
                            data-v-68d67528="" class="el-icon-lx-global"></i><span data-v-68d67528="">特征查询</span></li>
                </ul>
            </div>

            <!-- 内容部分 -->
            <div class="content-box">
                <div class="content">
                    <div>
                        <div class="crumbs">
                            <el-breadcrumb separator="/">
                                <el-breadcrumb-item>
                                    <i class="el-icon-lx-calendar"></i> 人脸库管理
                                </el-breadcrumb-item>
                                <el-breadcrumb-item>{{title}}</el-breadcrumb-item>
                            </el-breadcrumb>
                        </div>
                        <div class="container">
                            <div class="form-box">
                                <el-page-header @back="back"></el-page-header>
                                <el-form ref="form" :model="form" label-width="200px">
                                    <el-form-item  label="人脸库名称">
                                        <el-input v-model="form.set_name"></el-input>
                                    </el-form-item>
                                    <el-form-item label="底库特征模型版本号">
                                        <el-select v-model="form.model_version" placeholder="请选择">
                                            <el-option
                                                    v-for="item in model_versionOptions"
                                                    :key="item.value"
                                                    :label="item.label"
                                                    :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item  label="底库类型">
                                        <el-radio-group v-model="form.set_type" style="margin-top: 12px;;">
                                            <el-radio label="10">静态底库</el-radio>
                                            <el-radio label="20">动态底库</el-radio>
                                            <el-radio label="30">抓拍库</el-radio>
                                            <el-radio label="40">聚类中心底库</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <el-form-item  label="特征维度">
                                        <el-input type="number" v-model="form.feature_size" min="0" placeholder="0"></el-input>
                                    </el-form-item>
                                    <el-form-item  label="租户ID(人脸库所有者ID)">
                                        <el-input v-model="form.app_id"></el-input>
                                    </el-form-item>
                                    <el-form-item  label="人脸库最大能够存储ID数量">
                                        <el-input type="number" v-model="form.capacity" min="0" placeholder="0"></el-input>
                                    </el-form-item>
                                    <nav aria-label="breadcrumb">
                                        <ol class="breadcrumb">
                                            <li class="breadcrumb-item active" aria-current="page">人脸库加载策略</li>
                                        </ol>
                                    </nav>
                                    <el-form-item  label="分片规则">
                                        <el-radio-group v-model="form.strategy.slice_type" style="margin-top: 12px;;">
                                            <el-radio label="logic"></el-radio>
                                            <el-radio label="cluster"></el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <el-form-item  label="分片个数">
                                        <el-input type="number" v-model="form.strategy.slice_num" min="0" value="0"></el-input>
                                    </el-form-item>
                                    <el-form-item  label="副本数">
                                        <el-input type="number" v-model="form.strategy.replication" min="1" value="1"></el-input>
                                    </el-form-item>
                                    <el-form-item  label="检索类型">
                                        <el-radio-group v-model="form.strategy.search_type" style="margin-top: 12px;;">
                                            <el-radio label=0>CPU</el-radio>
                                            <el-radio label=1>GPU</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <el-form-item  label="聚类中心">
                                        <el-input v-model="form.strategy.cluster_center"></el-input>
                                    </el-form-item>
                                    <el-form-item  label="特征存储数据库名称">
                                        <el-input v-model="form.strategy.db_name"></el-input>
                                    </el-form-item>
                                    <el-form-item>
                                        <el-button type="primary" @click="onSubmit">{{btnText}}</el-button>
                                        <el-button @click="cancel">取消</el-button>
                                    </el-form-item>
                                </el-form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        var manage = new Vue({
            el: '#manage',
            data: {
                fullscreen: false,
                editId: '',
                title: '人脸库新增',
                btnText: '添加',
                form: {
                    set_name: null,
                    model_version: null,
                    set_type: '10',
                    feature_size: null,
                    app_id: null,
                    capacity: null,
                    strategy: {
                        slice_type: 'logic',
                        slice_num: null,
                        replication: null,
                        search_type: '0',
                        cluster_center: null,
                        db_name: null
                    }
                }
            },
            watch: {

            },
            computed: {
                username() {
                    let username = localStorage.getItem('ms_username');
                    return username ? username : this.name;
                }
            },
            mounted() {

            },
            created() {
                // 获取编辑的参数
                this.editId=getQueryString('id')
                if(this.editId==1){
                    this.title='人脸库编辑'
                    this.btnText='编辑'
                }else{
                    this.title='人脸库新增'
                    this.btnText='添加'
                }
            },
            methods: {

                // 返回
                back() {
                    window.history.back(-1);
                },

                onSubmit() {
                    if (this.form.set_name == null) {
                        this.$message.error("人脸库名称不能为空！");
                    }else {
                        axiosPostRequest('/api/library/create', this.form)
                            .then(result => {
                                if (result.status == 200) {
                                    this.$message.success('新增人脸库成功');
                                } else {
                                    this.$message.error(result.message);
                                }
                            })

                    }
                },
                cancel() {
                    window.history.back(-1); 
                },
                // 用户名下拉菜单选择事件
                handleCommand(command) {
                    if (command == 'loginout') {
                        localStorage.removeItem('ms_username');
                        window.localStorage["token"] = '';
                        window.location.href = 'login';
                    }
                },
                // 全屏事件
                handleFullScreen() {
                    let element = document.documentElement;
                    if (this.fullscreen) {
                        if (document.exitFullscreen) {
                            document.exitFullscreen();
                        } else if (document.webkitCancelFullScreen) {
                            document.webkitCancelFullScreen();
                        } else if (document.mozCancelFullScreen) {
                            document.mozCancelFullScreen();
                        } else if (document.msExitFullscreen) {
                            document.msExitFullscreen();
                        }
                    } else {
                        if (element.requestFullscreen) {
                            element.requestFullscreen();
                        } else if (element.webkitRequestFullScreen) {
                            element.webkitRequestFullScreen();
                        } else if (element.mozRequestFullScreen) {
                            element.mozRequestFullScreen();
                        } else if (element.msRequestFullscreen) {
                            // IE11
                            element.msRequestFullscreen();
                        }
                    }
                    this.fullscreen = !this.fullscreen;
                },
            }
        })

    </script>

</body>

</html>